package parser;

import java.util.ArrayList;
import java.util.List;
import ws.StringArray;

public class Utils {

    public static List<String> toList(String[] data) {
        List<String> list = new ArrayList<String>();
        for (int i = 0; i < data.length; i++) {
            list.add(data[i]);
        }
        return list;
    }

    public static String[][] toArrays(List<StringArray> answer) {
        int countRows = answer.size();
        if(countRows == 0){
            return null;
        }
        int countCells = answer.get(0).getItem().size();

        String[][] a = new String[countRows][countCells];

        for (int i = 0; i < countRows; i++) {

            a[i] = answer.get(i).getItem().toArray(new String[countCells]);

        }

        return a;

    }
}
